package gui.cen.read;

import core.utils.EPara;
import gui.cen.Center;
import gui.utils.Borders;
import gui.utils.Para;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.text.DecimalFormat;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

/*Author: John Archer, Contact: john.archer.jpa@gmail.com*/
public class CurrFilter extends JPanel {
    public static int HEIGHT_OF_FILTER = 40;
    private JLabel lab;
    private DecimalFormat df = new DecimalFormat("#0.00");
    public CurrFilter(){
        super(new BorderLayout());
        this.setPreferredSize(new Dimension(Center.WIDGE_WIDTH, HEIGHT_OF_FILTER));
        setBackground(new Color(102, 102, 102));
        setBorder(BorderFactory.createLineBorder(new Color(178, 178, 178), 2));

        JPanel p = new JPanel();
        p.setOpaque(false);
        p.setBorder(BorderFactory.createEmptyBorder(0,5,0,5));
        p.setLayout(new GridLayout(1,1));
        lab = new JLabel("CURRENT FILTER LEVEL: 0.00");
        lab.setFont(Borders.getFont(Borders.GUIFONT));
        lab.setForeground(Color.RED);
        lab.setBorder(BorderFactory.createEmptyBorder(0,4,0,0));
        p.add(lab);
        this.add(p, BorderLayout.CENTER);
    }

    public void setFilterLab(){
        if(Para.POSTS!=null){lab.setText("CURRENT FILTER LEVEL: "+df.format((double)EPara.POSTFILT/100.00)+"");}
        else{lab.setText("CURRENT FILTER LEVEL: 0.00");}
    }
}
